<template>
	<view class="padding-20 containear">
		<view class="nav-wrapper">
			<view style="background-color: transparent;" class="status-bar-height"></view>
			<image class="nav-bg pos-fill" src="http://jiaoyukehu.oss-cn-beijing.aliyuncs.com/static//my/nav_bg.png" mode=""></image>
		</view>
		<view class="size-box"></view>
		<ScrollView
			:contentHeight="contentHeight"
		>
			<template #content>
				<UserCard :userInfo="userInfo" />
				<view style="margin-top: 32rpx;">
					<PartnerShip />
				</view>
				<view style="margin-top: 16rpx; margin-bottom: 20rpx;">
					<NavItem :dataItem="myNavList[0]">
						<template #left>
							<view class="font24 color-8E8E8E m-l-20">可添加5人</view>
						</template>
						<template #right>
							<view class="font24 f-b color-3FA897" @click="goPage">新建档案</view>
						</template>
					</NavItem>
				</view>
				<view class="m-t-20 bg-w nav-list">
					<block v-for="(item, index) in myNavList" :key="index">
						<NavItem v-if="index != 0" :dataItem="item" />
					</block>
				</view>
				<view style="height: 56rpx;"></view>
			</template>
		</ScrollView>
		
		<bottom type="accompany" :tabIndex="4"></bottom>
	</view>
</template>

<script lang="ts" setup>
	import bottom from '@/components/footer/footer.vue';
	import ScrollView from '@/components/accompany/scrollView/scrollView.vue';
	import UserCard from '@/components/accompany/tabbar/my/userCard/index.vue'
	import PartnerShip from './components/partnership/index.vue'
	import NavItem from '@/components/accompany/tabbar/my/navItem/index.vue';
	
	import { ref,getCurrentInstance,reactive } from 'vue';
	import type { Ref } from 'vue'
	import { onLoad,onShow } from '@dcloudio/uni-app';
	
	import { myNavList } from '@/config/config';
	const contentHeight:Ref<number> = ref(0)	
	const {proxy} = getCurrentInstance() as any
	let userInfo = ref({
		avatar: '',
		userName: '',
		grade: ''
		// avatar: 'https://img0.baidu.com/it/u=1385079478,4019721997&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
		// userName: '前端开发',
		// grade: 'LV1'
	})
	console.log(UserCard)
	// let dataList = reactive({
	// 	userInfo:{}
	// })
	// function getUserInfo() {
	// 	let url = proxy.$API.getUserInfo
	// 	console.log(proxy.$API.getUserInfo, 'login')
	// 	proxy.$UNIHTTP.getData(url, {}).then((res: any) => {
	// 		console.log(res, 'res')
	// 		if (res) {
	// 			if (res.code == 0) {
	// 				// avatar: "https://pmxcxmb.shiliucrm.com/site/static/goods/source/202303222004568975e09711d2b05b0eaa9563ad2bfbb1664f.jpg"
	// 				// mobile: "19560348352"
	// 				// nickname: "王小二"
	// 				userInfo.value = res.data
	// 				console.log(userInfo.avatar,'userInfo')
	// 				uni.setStorageSync('userInfo',userInfo)
	// 			} else if (res.msg) {
	// 				uni.showToast({
	// 					title: res.msg, //显示的文字 
	// 				})
	// 			}
	// 		} else {
	// 			uni.showToast({
	// 				title: '系统错误', //显示的文字 
	// 			})
	// 		}
	// 	})
	// }
	onShow(() => {
		let userInfoTemp = uni.getStorageSync('userInfo')
		console.log(userInfoTemp,'userInfoTemp')
		if(userInfoTemp){
			userInfo.value = userInfoTemp
		}else{
			// getUserInfo()
		}
	})
	onLoad (() => {
		console.log('onLoad')
		// let userInfoTemp = uni.getStorageSync('userInfo')
		// console.log(userInfoTemp,'userInfoTemp')
		// if(userInfoTemp){
		// 	userInfo.value = userInfoTemp
		// }else{
		// 	// getUserInfo()
		// }
		
		
		let sysInfo = uni.getStorageSync('sysInfo')
		contentHeight.value = sysInfo.screenHeight - sysInfo.statusBarHeight - 94
		console.log(contentHeight)
		let loginInfo = uni.getStorageSync('loginInfo')
		if(!loginInfo){
			uni.navigateTo({
				url:'login/login'
			})
		}
		
	})
	function goPage() {
		uni.navigateTo({
			url: '/pages/accompany-tmp/my/addArchives/addArchives'
		})
	}
</script>

<style lang="scss" scoped>
	.containear {
		background-color: #F5F7FB;
	}
	.size-box {
		height: 88rpx;
		padding-bottom: var(--status-bar-height);
	}
	.nav-wrapper {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		padding: 0 20rpx;
		height: 488rpx;
		.nav-bg {
			width: 100%;
			height: 488rpx;
		}
		.nav-box {
			height: 88rpx;
			position: relative;
			font-weight: 500;
			color: #181D18;
			.left-text {
				font-size: 28rpx;
				margin-left: 8rpx;
			}
			.title {
				font-size: 36rpx;
			}
		}
	}
	.nav-list {
		border-radius: 32rpx;
	}
</style>